package com.happyclub.lcy.dao;


import com.happyclub.pojo.TbTourTeam;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;


public interface ITeam extends JpaRepository<TbTourTeam,String> {
//创建驴友队
    @Modifying
    @Query(value = "insert into TB_TOUR_TEAM(ID,TEAM_ID,LEADER_ID,TEAM_LOGO,LOCALTION,MAIN_PROJECT,INTRO,MANIFESTO,PRINCIPAL_NAME,PRINCIPAL_TELPHONE,PHOTO_ALBUM_ID,TOUR_ID,UPDATE_TIME,CREATE_TIME,TEAM_NAME) VALUES(?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14,?15)",nativeQuery = true)
    int insertTourTeam(String id, String team_id, String leaderId, String teamLogo, String localtion, String main_projec, String intro, String manifesto, String principalName, String principalTelphone, String photoAlbumId, String tourId, String createTime, String updateTime, String teamName);

    //加入驴友队，先根据队伍id查到队伍 在往用户队伍中间表,队伍角色，用户角色表里插值
    @Query(value = "select tt from TbTourTeam tt where tt.teamId=:teamId")
    TbTourTeam selectTeamById(@Param("teamId") String teamId);
//查询该角色的所加入的所有队伍信息
    @Modifying
    @Query(value = "select * from TB_TOUR_TEAM where TEAM_ID in (select TB_USER_ROLE_MAP.TEAM_ID from TB_USER_ROLE_MAP where USER_ID = ?1)" ,nativeQuery = true)
    List<TbTourTeam> getAllTeamInforByUserId(String userId);
}

